<template>
  <div class="login-bg">
    <div class="login-content">
      <div class="login-l"></div>
      <div class="login-msg">
        <div class="login-title">
          <span>欢迎使用</span>
          <span>智慧医疗问答系统</span>
        </div>
        <div class="login-name">
          <label for="username">昵称</label>
          <el-input @keyup.enter.native="login" size="medium" style="width:200px" class="login-ipt" v-model="username" placeholder="请输入您的昵称" clearable></el-input>
        </div>
        <div class="login-btn">
          <el-button type="primary" style="width:150px"  @click="login">进入问答系统</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data () {
    return {
      username: ''
    }
  },
  methods: {
    login () {
      if (this.username === '') {
        this.$message({
          message: '请输入昵称',
          type: 'warning'
        })
        return
      }
      if (this.username === 'feedback') {
        this.$message({
          message: '无效的昵称，换一个输入吧!',
          type: 'warning'
        })
        this.username = ''
        return
      }
      // 昵称不为空就可以进去问答系统
      this.$router.push({
        name: 'chat'
      })
      window.localStorage.setItem('token', JSON.stringify(this.username))
    }
  }
}
</script>

<style scoped>
*{
  margin: 0;
  padding: 0;
}

.login-bg{
  background: rebeccapurple;
  position: relative;
  width: 100%;
  height: 100%;
  background: url('~@/assets/img/bg1.png');
  /* filter: blur(10px); */
  background-size: 100% 100%;
}
.login-content{
  position: absolute;
  width: 700px;
  height: 400px;
  left: 50%;
  top: 50%;
  border-radius: 5px 5px;
  transform: translate(-50%,-50%);
  overflow: hidden;
  box-shadow:0 0 0 1px hsla(0,0%,100%,.3) inset,0 .5em 1em rgba(0,0,0,0.6);
  display: flex;
}

.login-l{
  width: 50%;
  height: 100%;
  background: url('~@/assets/img/bg3.png');
  background-size: 100% 100%;
  font-size: 30px;
  font-weight: bolds;
}
.login-msg{
  width: 50%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  color: rgb(88, 88, 88);
  /* margin-top: 30px; */
}
.login-title{
  margin-top: 55px;
  font-size: 30px;
  font-weight: bolds;
}
.login-title span{
  display: block;
  margin: 10px 0;
}
.login-name,.login-btn{
  margin:50px auto;
}
.login-ipt{
  padding-left: 10px;
}
</style>
